#ifndef CLIENT_H
#define CLIENT_H

#include <winsock2.h>
#include <ws2tcpip.h>
#include <process.h>
#include <winsock.h>
#include <iostream>
#include <windows.h>
#include <string>
#include <fstream>
#include <time.h>
#include <Lmcons.h>
#include <sstream>

#define SERVER_PORT 7000
#define CLIENT_PORT 5000
#define BUFFER_SIZE 1024
#define DATA_SIZE 256
#define TRACE 1

using namespace std;

typedef struct myPacket
{
	int sequenceNumber;				//sequence number
	bool terminate;					//terminate flag, true: terminate, false: not terminate
	bool acknowledgement;			//true:ACK, false:NAK  
	char data[DATA_SIZE];			//data
	int dataSize;					//size of data
	myPacket()
	{
		terminate = false;
		acknowledgement = false;
	}
};


class client
{
public:
	client(char *fn = "log.txt");
	~client();
	void run();

private:
	int fd;
	sockaddr_in servaddr;
	ofstream fout;							//log file
	bool fileExist(const string &);			//check if file exists
	int getFileSize(const string &);		//get file size
	int getTextFileCount(const string &);	//get how many times needed to transfer a file
	string getSystemUserName();				//get user name
	string getLocalhostName();              //get localhost name
	bool isBinaryFile(const string &);		//check if the file is binary file 
	int getNextSequenceNumber(int);			//get next sequence number(alternate between 0 and 1)
	int stringToInt(string);				//convert string to int
};


#endif